package com.ningxia.water.utils;

import java.math.RoundingMode;
import java.text.NumberFormat;

/**
 * @author huangzhen
 * @create 2021-04-21 16:01
 */
public class NumberUtils {
    private  static volatile NumberFormat nf ;
    public static NumberFormat getInstance() {
        if (nf == null){
            synchronized (NumberUtils.class){
                if (nf == null){
                    nf = NumberFormat.getNumberInstance();
                    //保留5位小数
                    nf.setMaximumFractionDigits(5);
                    //四拾伍入
                    nf.setRoundingMode(RoundingMode.HALF_UP);
                }
            }
        }
        return nf;
    }
}
